textviewchild: Don't leak children
authorMatthias Clasen <mclasen@redhat.com>
Tue, 12 May 2020 00:31:14 +0000 (20:31 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 12 May 2020 00:33:23 +0000 (20:33 -0400)
Like everybody else, GtkTextViewChild must
unparent its children in dispose.

gtk/gtktextviewchild.c

index 1462f3ecbdc01f35374bca1920274ff46da06501..a8a42278d14e6fb9d942ca638b0967e784659539 100644 (file)
@@ -373,6 +373,18 @@ gtk_text_view_child_set_property (GObject      *object,
     }
 }
 
+static void
+gtk_text_view_child_dispose (GObject *object)
+{
+  GtkTextViewChild *self = GTK_TEXT_VIEW_CHILD (object);
+  GtkWidget *child;
+
+  while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
+    gtk_text_view_child_remove (self, child);
+
+  G_OBJECT_CLASS (gtk_text_view_child_parent_class)->dispose (object);
+}
+
 static void
 gtk_text_view_child_class_init (GtkTextViewChildClass *klass)
 {
@@ -380,6 +392,7 @@ gtk_text_view_child_class_init (GtkTextViewChildClass *klass)
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
   GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
 
+  object_class->dispose = gtk_text_view_child_dispose;
   object_class->constructed = gtk_text_view_child_constructed;
   object_class->get_property = gtk_text_view_child_get_property;
   object_class->set_property = gtk_text_view_child_set_property;